#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

vector<string> filenames;

void print(string str,int len,char extra){
	cout<<str ;
	for(int i=0;i<len-(str.length());i++){
		cout<<extra;
	}
}

int main()
{
	int n=0;
	int cols=0,rows=0;
	while(cin >> n){
		int M=0;
		string s;
		for(int i=0;i<n;i++){
			cin >> s;
			filenames.push_back(s);
			M = max(M,(int)s.length());
		}
		cols = (60 - M) / (M + 2) +1;
		rows = (n - 1) / cols + 1;
		print("",60,'-');
		cout<<endl;
		sort(filenames.begin(),filenames.end());
		for(int i=0;i<rows;i++){
			for(int j=0;j<cols;j++){
				int idx = j*rows + i;
				if(idx < n)
					print(filenames[idx],j == (cols-1) ? M : M+2, ' ');
			}
			cout<<endl;
		}
	}
	return 0;
}
